package handle

import (
	"SortSet/server/resp"
	"SortSet/server/store"
	"encoding/json"
	"io/ioutil"
	"net/http"
)

func Remove(writer http.ResponseWriter, request *http.Request) error {
	requestBytes, err := ioutil.ReadAll(request.Body)
	if err != nil {
		return err
	}
	datas := make([]string, 0)
	err = json.Unmarshal(requestBytes, &datas)
	if err != nil {
		return err
	}
	store.GlobalSet.RemoveAll(datas...)
	resp.NewRespAndWriteDirect(
		200,
		"success",
		nil,
		writer)
	return nil
}
